home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / rkeyboar.cpt / Reactive Keyboard ƒ / AdjustCursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-27  |  15.5 KB  |  471 lines

  1. #include <MacIncludes.h>
  2. #include "Rk.h"
  3. #include "Structs.h"
  4. #include "file+rk.h"
  5. #include "Offscreen.h"
  6. #include <CType.h>
  7.  
  8. #define TopLeft(aRect)    (* (Point *) &(aRect).top)
  9. #define BotRight(aRect)    (* (Point *) &(aRect).bottom)
  10.  
  11. #define PRED_CLIP 0
  12. #define TEXT_CLIP 1
  13.  
  14. void AdjustCursor (Point mouse, RgnHandle region );
  15. void AdjustCurPred(Point mouse, RgnHandle region, WindowPtr window);
  16. void AdjustCurText(Point mouse, RgnHandle region, WindowPtr window);
  17.  
  18.  
  19. extern    void SpecialLine(char *line,char *prediction);
  20.  
  21.  
  22. extern Boolean        gInBackground;        /* maintained by Initialize and DoEvent */
  23. extern WindowPtr    gPredict,gText;
  24. extern short        gContextBar;
  25. extern FontInfo     gFInfo,gNormFInfo;
  26. extern GrafPort     goffScreen;
  27. extern Ptr            Hilite;
  28. extern int            gSelLine, gSelChar;
  29. extern Rect            gHiliteRect;
  30. extern int            pred_number;
  31. extern short        gPredScrollNum;
  32. extern Boolean        gNewLine;
  33. extern pascal void    nullEraseRect(GrafVerb verb,const Rect *r);
  34.  
  35.  
  36.  
  37.  
  38. #pragma segment Main2
  39. void AdjustCursor(Point mouse,RgnHandle region)
  40. {
  41.     WindowPtr    window;
  42.     
  43.  
  44.     window = FrontWindow();    /* we only adjust the cursor when we are in front */
  45.     if ( (! gInBackground) && (! IsDAWindow(window)) ) {
  46.         if(window==gText){
  47.             AdjustCurText(mouse, region, window);        
  48.         } else if(window==gPredict){
  49.             AdjustCurPred(mouse, region, window);
  50.         }else
  51.             SetCursor(&qd.arrow);
  52.     }
  53. } /* AdjustCursor */
  54.  
  55. void AdjustCurPred(Point mouse,RgnHandle region, WindowPtr window)
  56. {
  57.     RgnHandle    arrowRgn;
  58.     RgnHandle    iBeamRgn;
  59.     RgnHandle    MoveRgn;
  60.     RgnHandle    CharRgn;
  61.     Rect        Clip;
  62.     Rect        MoveRect;
  63.     Rect        CharRect;
  64.     Rect        ContextRect;
  65.     Rect        iBeamRect;
  66.     Rect        TextRect;
  67.     Rect        globalRect;
  68.     char         prediction[100];
  69.     char        line[100];
  70.     char        buffer[100];
  71.     int            Count;
  72.     CharsHandle    TEText;
  73.     TEHandle    te;
  74.     Boolean     drawNeeded;
  75.     BitMapPtr    backMap,selectMap;
  76.     GrafPort    store= *window;
  77.  
  78.  
  79.     te = ((DocumentPeek) gText)->docTE;
  80.  
  81.     /* calculate regions for different cursor shapes */
  82.     arrowRgn = NewRgn();
  83.     iBeamRgn = NewRgn();
  84.      MoveRgn = NewRgn();
  85.      CharRgn = NewRgn();
  86.  
  87.     /* start arrowRgn wide open */
  88.     SetRectRgn(arrowRgn, kExtremeNeg, kExtremeNeg, kExtremePos, kExtremePos);
  89.     
  90.     SetRect(&MoveRect,gContextBar-1,
  91.                       0,
  92.                       gContextBar+2,
  93.                       gPredict->portRect.bottom-gPredict->portRect.top-16);
  94.     iBeamRect=gPredict->portRect;
  95.     iBeamRect.bottom=((gPredict->portRect.bottom-20)/
  96.         (gFInfo.ascent+gFInfo.descent+gFInfo.leading))
  97.         *(gFInfo.ascent+gFInfo.descent+gFInfo.leading);
  98.     iBeamRect.right-=16;
  99.  
  100.  
  101.     SetPort(window);        
  102.  
  103.     LocalToGlobal(&TopLeft(MoveRect));
  104.     LocalToGlobal(&BotRight(MoveRect));
  105.      LocalToGlobal(&TopLeft(iBeamRect));
  106.     LocalToGlobal(&BotRight(iBeamRect));
  107.  
  108.     RectRgn(MoveRgn, &MoveRect);
  109.     RectRgn(iBeamRgn, &iBeamRect);
  110.     
  111.     /* we temporarily change the port╒s origin to ╥globalfy╙ the visRgn */
  112. /*    SetOrigin(-window->portBits.bounds.left, -window->portBits.bounds.top);
  113.     SectRgn(MoveRgn, window->visRgn, MoveRgn);
  114.     SectRgn(iBeamRgn, window->visRgn, iBeamRgn);
  115.     SetOrigin(0, 0);
  116. */
  117.     /* subtract other regions from arrowRgn */
  118.     DiffRgn(arrowRgn, MoveRgn, arrowRgn);
  119.     DiffRgn(arrowRgn, iBeamRgn, arrowRgn);
  120.     
  121.  
  122.     /* change the cursor and the region parameter */
  123.     if ( PtInRgn(mouse, MoveRgn ) ) {
  124.         SetCursor(*GetCursor(rMoveBarCursor));
  125.         CopyRgn(MoveRgn, region);
  126.         UpdateContext(te);
  127.     } else if ( PtInRgn(mouse, iBeamRgn) ){
  128.         SetPort(gPredict);
  129.         PushClip(PRED_CLIP);
  130.         SetRect(&Clip,window->portRect.left,window->portRect.top,window->portRect.right-15, window->portRect.bottom-15);
  131.         ClipRect(&Clip);
  132.  
  133.         GlobalToLocal(&mouse);
  134.         if(mouse.h>=gContextBar){
  135.             GetGlobalRect(gPredict,&globalRect);
  136.             if(CheckBoundsOffscreen(((OffscreenPeek)window)->fBackHandle,&globalRect, &drawNeeded)) debugstr("No Memory in AdjustCurPred")/* Handle Memerr? */;
  137.             if(drawNeeded){
  138.                 BeginOffscreenDrawing(((OffscreenPeek)window)->fBackHandle,window);
  139.                 EraseRect(&window->portRect);
  140.                 ReDrawPredictions(); 
  141.                 EndOffscreenDrawing(((OffscreenPeek)window)->fBackHandle);
  142.             }
  143.             backMap   = GetMap(((OffscreenPeek)window)->fBackHandle);
  144.             selectMap = GetMap(((OffscreenPeek)window)->fSelectHandle);
  145.             
  146.             if(backMap){
  147.                 ForeColor(blackColor);
  148.                 BackColor(whiteColor);
  149.                 if(selectMap){
  150.                     CopyBits(backMap, selectMap, &window->portRect, &window->portRect, srcCopy, nil);
  151.                 }
  152.                 ValidRectOffscreen(((OffscreenPeek)window)->fBackHandle, nil, &window->portRect);
  153.             }
  154.             pred_number=(mouse.v-2)/
  155.                 (gFInfo.ascent+gFInfo.descent+gFInfo.leading)+gPredScrollNum;
  156.             if (pred_number<0) pred_number=0;
  157.             *window=store;
  158.             SetPort(gPredict);
  159.             SetRect(&Clip,window->portRect.left,window->portRect.top,window->portRect.right-15, window->portRect.bottom-15);
  160.             ClipRect(&Clip);
  161.             InvalRectOffscreen(((OffscreenPeek)window)->fSelectHandle,nil,&Clip);
  162.             if(CheckBoundsOffscreen(((OffscreenPeek)window)->fSelectHandle,&globalRect, &drawNeeded)) debugstr("No Memory in AdjustCurPred");/* Handle Memerr? */;    
  163.             BeginOffscreenDrawing(((OffscreenPeek)window)->fSelectHandle,window); 
  164.             SetRect(&ContextRect,0,0,gContextBar,gPredict->portRect.bottom-18);
  165.             EraseRect(&ContextRect);
  166.             TEText=TEGetText(te);
  167.             for(Count=(*te)->selStart;(Count>0)&&
  168.                 ((TextWidth((Ptr)(*TEText),Count,(*te)->selStart-Count))<(gContextBar-2))
  169.                 ;Count--);
  170.             strncpy(buffer,((char *)*TEText)+Count,(*te)->selStart-Count);
  171.             SpecialLine(buffer,buffer);
  172.             if((*te)->selStart==0){
  173.                 MoveTo((gContextBar-2)-TextWidth("(NONE)",0,6),
  174.                     (pred_number-gPredScrollNum)*
  175.                     (gFInfo.ascent+gFInfo.descent+gFInfo.leading)+4+(gFInfo.ascent));
  176.                 DrawString("\p(NONE)");
  177.             }else{
  178.                 MoveTo((gContextBar-2)-TextWidth(buffer,0,
  179.                     (*te)->selStart-Count),
  180.                     (pred_number-gPredScrollNum)*
  181.                     (gFInfo.ascent+gFInfo.descent+gFInfo.leading)+4+(gFInfo.ascent));
  182.                 DrawText(buffer,0,(*te)->selStart-Count);
  183.             }
  184.             make_a_prediction(prediction);
  185.             SpecialLine(line,prediction);
  186.             Count=1;
  187.             while(((TextWidth(line,0,Count++)+gContextBar+5)<mouse.h) 
  188.                     && *(line+Count-1));
  189.             
  190.             Count--; 
  191.             SetRect(&CharRect,
  192.                 TextWidth(line,0,Count-1)+gContextBar+5,
  193.                 (pred_number-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2,
  194.                 TextWidth(line,0,Count)+gContextBar+5,
  195.                 (pred_number+1-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2);
  196.             gSelChar=Count;
  197.         
  198.             SetRect(&gHiliteRect,gContextBar+5,
  199.                 (pred_number-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2,
  200.                 TextWidth(line,0,Count)+gContextBar+5,
  201.                 (pred_number+1-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2);
  202.             
  203.             BitClr(Hilite,pHiliteBit);
  204.             InvertRect(&gHiliteRect);
  205.             EndOffscreenDrawing(((OffscreenPeek)window)->fSelectHandle);
  206.             selectMap = GetMap(((OffscreenPeek)window)->fSelectHandle);
  207.             if(selectMap){
  208.                 ForeColor(blackColor);
  209.                 BackColor(whiteColor);
  210.                 CopyBits(selectMap, &qd.thePort->portBits, &gPredict->portRect, &gPredict->portRect, srcCopy, nil);
  211.                 ValidRectOffscreen(((OffscreenPeek)window)->fSelectHandle,gPredict,&Clip);
  212.             }    
  213.             if((*te)->teLength<=(*te)->selStart ) { 
  214.                 QDProcs theprocs,*oldprocs;
  215.                 Rect BackRect;
  216.                 char line[100];
  217.                 
  218.                 
  219.                 SpecialLine(line,prediction);
  220.                 
  221.                 /* this is REALLY GROSS, but should be portable with no problem
  222.                    TextEdit does not update the selRect until you make TE calls
  223.                    so we call TEDelete and patch EraseRect so it doesn't refresh
  224.                    the window */
  225.                    
  226.                 SetPort(gText);
  227.                 SetStdProcs(&theprocs);
  228.                 theprocs.rectProc=(Ptr)nullEraseRect;
  229.                 oldprocs=gText->grafProcs;
  230.                 gText->grafProcs=&theprocs;
  231.     
  232.                 TEDelete(((DocumentPeek)gText)->docTE);
  233.                 gText->grafProcs=oldprocs;                    
  234.                 
  235.     
  236.                 SetRect(&TextRect,(*te)->selRect.left
  237.                                     ,(*te)->selRect.top,
  238.                                     (*te)->selRect.left+(goffScreen.portBits.bounds.right -
  239.                                     goffScreen.portBits.bounds.left),
  240.                                     (*te)->selRect.top+
  241.                                     gNormFInfo.ascent+gNormFInfo.descent
  242.                                     +gNormFInfo.leading);
  243.                 SetPort(&goffScreen);
  244.                 EraseRect(&goffScreen.portRect);
  245.                 BackRect=qd.thePort->portRect;
  246.                 BackRect.right=TextWidth(line,0,Count)+2;
  247.                 PaintRect(&BackRect);
  248.                 TextMode(srcBic);
  249.                 MoveTo(1,gNormFInfo.ascent+gNormFInfo.leading-1);
  250.                 DrawText(line,0,Count);
  251.                 SetPort(gText);
  252.                 PushClip(TEXT_CLIP);
  253.                 ClipRect(&(*te)->viewRect);
  254.                 CopyBits(&goffScreen.portBits,&qd.thePort->portBits,
  255.                         &goffScreen.portRect,&TextRect,srcCopy,NULL);
  256.                 PopClip(TEXT_CLIP);
  257.             }
  258.             SetPort(gPredict);
  259.             LocalToGlobal(&TopLeft(CharRect));
  260.             LocalToGlobal(&BotRight(CharRect));
  261.             RectRgn(CharRgn, &CharRect);
  262.             SetOrigin(-window->portBits.bounds.left, -window->portBits.bounds.top);
  263.             SectRgn(CharRgn, window->visRgn, CharRgn);
  264.             SetOrigin(0, 0);            
  265.             SetCursor(*GetCursor(iBeamCursor));
  266.             CopyRgn(CharRgn, region);
  267.         } else { /* reverse Select */
  268.             SetRect(&TextRect,(*te)->selRect.left
  269.                 ,(*te)->selRect.top,
  270.                 (*te)->selRect.left+(goffScreen.portBits.bounds.right -
  271.                 goffScreen.portBits.bounds.left),
  272.                 (*te)->selRect.top+
  273.                 gNormFInfo.ascent+gNormFInfo.descent
  274.                 +gNormFInfo.leading);
  275.             SetPort(gText);
  276.             PushClip(TEXT_CLIP);
  277.             ClipRect(&(*te)->viewRect);
  278.             EraseRect(&TextRect);
  279.             PopClip(TEXT_CLIP);
  280.  
  281.             GetGlobalRect(gPredict,&globalRect);
  282.             if(CheckBoundsOffscreen(((OffscreenPeek)window)->fBackHandle,&globalRect, &drawNeeded)) debugstr("No Memory in AdjustCurPred")/* Handle Memerr? */;
  283.             if(drawNeeded){
  284.                 BeginOffscreenDrawing(((OffscreenPeek)window)->fBackHandle,window);
  285.                 EraseRect(&window->portRect);
  286.                 ReDrawPredictions(); 
  287.                 EndOffscreenDrawing(((OffscreenPeek)window)->fBackHandle);
  288.             }
  289.             backMap   = GetMap(((OffscreenPeek)window)->fBackHandle);
  290.             selectMap = GetMap(((OffscreenPeek)window)->fSelectHandle);
  291.             
  292.             if(backMap){
  293.                 ForeColor(blackColor);
  294.                 BackColor(whiteColor);
  295.                 if(selectMap){
  296.                     CopyBits(backMap, selectMap, &window->portRect, &window->portRect, srcCopy, nil);
  297.                 }
  298.                 ValidRectOffscreen(((OffscreenPeek)window)->fBackHandle, nil, &window->portRect);
  299.             }
  300.             pred_number=(mouse.v-2)/
  301.                 (gFInfo.ascent+gFInfo.descent+gFInfo.leading)+gPredScrollNum;
  302.             if (pred_number<0) pred_number=0;
  303.             *window=store;
  304.             SetPort(gPredict);
  305.             SetRect(&Clip,window->portRect.left,window->portRect.top,window->portRect.right-15, window->portRect.bottom-15);
  306.             ClipRect(&Clip);
  307.             InvalRectOffscreen(((OffscreenPeek)window)->fSelectHandle,nil,&Clip);
  308.             if(CheckBoundsOffscreen(((OffscreenPeek)window)->fSelectHandle,&globalRect, &drawNeeded)) debugstr("No Memory in AdjustCurPred");/* Handle Memerr? */;    
  309.             BeginOffscreenDrawing(((OffscreenPeek)window)->fSelectHandle,window); 
  310.             SetRect(&ContextRect,0,0,gContextBar,gPredict->portRect.bottom-18);
  311.             EraseRect(&ContextRect);
  312.             if((*te)->selStart==0){
  313.                 MoveTo((gContextBar-2)-TextWidth("(NONE)",0,6),
  314.                     (pred_number-gPredScrollNum)*
  315.                     (gFInfo.ascent+gFInfo.descent+gFInfo.leading)+4+(gFInfo.ascent));
  316.                 DrawString("\p(NONE)");
  317.             }else{
  318.                 TEText=TEGetText(te);
  319.                 Count=(*te)->selStart - ((gContextBar-2)/CharWidth(' '));
  320.                 if(Count< 0 ) Count=0;
  321.                 strncpy(buffer,(Ptr) *TEText+Count, ((gContextBar-2)/CharWidth(' '))); 
  322.                 SpecialLine(buffer,buffer);
  323.                 MoveTo((gContextBar-2)-(CharWidth(' ')*((*te)->selStart-Count)),
  324.                     (pred_number-gPredScrollNum)*
  325.                     (gFInfo.ascent+gFInfo.descent+gFInfo.leading)+4+(gFInfo.ascent));
  326.                 DrawText(buffer,0,(*te)->selStart-Count);
  327.             }
  328.             Count=(*te)->selStart - (((gContextBar-2)-mouse.h)/CharWidth(' '));
  329.             if(Count< 0 ) Count=0;
  330.             SetRect(&CharRect,
  331.                 (gContextBar-2)-(CharWidth(' ')*(((gContextBar-2)-mouse.h)/CharWidth(' '))),
  332.                 (pred_number-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2,
  333.                 (gContextBar-2)-(CharWidth(' ')*(((gContextBar-2)-mouse.h)/CharWidth(' ')))+1,
  334.                 (pred_number+1-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2);
  335.             gSelChar=Count;
  336.         
  337.             SetRect(&gHiliteRect,
  338.                 (gContextBar-2)-(CharWidth(' ')*((*te)->selStart - Count)),
  339.                 (pred_number-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2,
  340.                 (gContextBar-2),
  341.                 (pred_number+1-gPredScrollNum)*(gFInfo.ascent+gFInfo.descent+gFInfo.leading)+2);
  342.             
  343.             BitClr(Hilite,pHiliteBit);
  344.             InvertRect(&gHiliteRect);
  345.             EndOffscreenDrawing(((OffscreenPeek)window)->fSelectHandle);
  346.             selectMap = GetMap(((OffscreenPeek)window)->fSelectHandle);
  347.             if(selectMap){
  348.                 ForeColor(blackColor);
  349.                 BackColor(whiteColor);
  350.                 CopyBits(selectMap, &qd.thePort->portBits, &gPredict->portRect, &gPredict->portRect, srcCopy, nil);
  351.                 ValidRectOffscreen(((OffscreenPeek)window)->fSelectHandle,gPredict,&Clip);
  352.             }    
  353.             SetPort(gPredict);
  354.             PopClip(PRED_CLIP);
  355.             LocalToGlobal(&TopLeft(CharRect));
  356.             LocalToGlobal(&BotRight(CharRect));
  357.             RectRgn(CharRgn, &CharRect);
  358.             SetOrigin(-window->portBits.bounds.left, -window->portBits.bounds.top);
  359.             SectRgn(CharRgn, window->visRgn, CharRgn);
  360.             SetOrigin(0, 0);            
  361.             SetCursor(*GetCursor(iBeamCursor));
  362.             CopyRgn(CharRgn, region);
  363.         }
  364.     } else {
  365.         SetCursor(&qd.arrow);
  366.         CopyRgn(arrowRgn, region);
  367.         UpdateContext(te);        
  368.     }
  369.  
  370.     DisposeRgn(arrowRgn);
  371.     DisposeRgn(MoveRgn );
  372.     DisposeRgn(iBeamRgn);
  373.     DisposeRgn(CharRgn );
  374.     *window=store;
  375. }
  376.  
  377. void AdjustCurText(Point mouse, RgnHandle region, WindowPtr    window)
  378. {
  379.  
  380.     Rect        iBeamRect;
  381.     RgnHandle    arrowRgn;
  382.     RgnHandle    iBeamRgn;
  383.     
  384.     /* calculate regions for different cursor shapes */
  385.     arrowRgn = NewRgn();
  386.     iBeamRgn = NewRgn();
  387.     
  388.     /* start arrowRgn wide open */
  389.     SetRectRgn(arrowRgn, kExtremeNeg, kExtremeNeg, kExtremePos, kExtremePos);
  390.     
  391.     /* calculate iBeamRgn */
  392.     if ( IsAppWindow(window) ) {
  393.         iBeamRect = (*((DocumentPeek) window)->docTE)->viewRect;
  394.         SetPort(window);    /* make a global version of the viewRect */
  395.         LocalToGlobal(&TopLeft(iBeamRect));
  396.         LocalToGlobal(&BotRight(iBeamRect));
  397.         RectRgn(iBeamRgn, &iBeamRect);
  398.         /* we temporarily change the port╒s origin to ╥globalfy╙ the visRgn */
  399.         SetOrigin(-window->portBits.bounds.left, -window->portBits.bounds.top);
  400.         SectRgn(iBeamRgn, window->visRgn, iBeamRgn);
  401.         SetOrigin(0, 0);
  402.     }
  403.     
  404.     /* subtract other regions from arrowRgn */
  405.     DiffRgn(arrowRgn, iBeamRgn, arrowRgn);
  406.     
  407.     /* change the cursor and the region parameter */
  408.     if ( PtInRgn(mouse, iBeamRgn) ) {
  409.         SetCursor(*GetCursor(iBeamCursor));
  410.         CopyRgn(iBeamRgn, region);
  411.     } else {
  412.         SetCursor(&qd.arrow);
  413.         CopyRgn(arrowRgn, region);
  414.     }
  415.     
  416.     DisposeRgn(arrowRgn);
  417.     DisposeRgn(iBeamRgn);
  418. }
  419.  
  420.  
  421.  
  422. UpdateContext(te)
  423. TEHandle te;
  424. {
  425.     Rect        globalRect;
  426.     Boolean        drawNeeded;
  427.     BitMapPtr    backMap,selectMap;
  428.     Rect        Clip;
  429.     Rect        TextRect;
  430.     
  431.     if((*te)->teLength<=(*te)->selStart){
  432.         TEDelete(((DocumentPeek)gText)->docTE);
  433.         SetRect(&TextRect,(*te)->selRect.left
  434.             ,(*te)->selRect.top,
  435.             (*te)->selRect.left+(goffScreen.portBits.bounds.right -
  436.             goffScreen.portBits.bounds.left),
  437.             (*te)->selRect.top+
  438.             gNormFInfo.ascent+gNormFInfo.descent
  439.             +gNormFInfo.leading);
  440.         SetPort(gText);
  441.         PushClip(TEXT_CLIP);
  442.         ClipRect(&(*te)->viewRect);
  443.         EraseRect(&TextRect);
  444.         PopClip(TEXT_CLIP);
  445.     }
  446.     SetPort(gPredict);
  447.     PushClip(PRED_CLIP);
  448.     SetRect(&Clip,gPredict->portRect.left,gPredict->portRect.top,gPredict->portRect.right-15, gPredict->portRect.bottom-15);
  449.     ClipRect(&Clip);
  450.  
  451.     GetGlobalRect(gPredict,&globalRect);
  452.     if(CheckBoundsOffscreen(((OffscreenPeek)gPredict)->fBackHandle,&globalRect, &drawNeeded)) debugstr("No Memory in AdjustCurPred")/* Handle Memerr? */;
  453.     if(drawNeeded){
  454.         BeginOffscreenDrawing(((OffscreenPeek)gPredict)->fBackHandle,gPredict);
  455.         EraseRect(&gPredict->portRect);
  456.         ReDrawPredictions(); 
  457.         EndOffscreenDrawing(((OffscreenPeek)gPredict)->fBackHandle);
  458.     }
  459.     backMap   = GetMap(((OffscreenPeek)gPredict)->fBackHandle);
  460.     selectMap = GetMap(((OffscreenPeek)gPredict)->fSelectHandle);
  461.     
  462.     if(backMap){
  463.         ForeColor(blackColor);
  464.         BackColor(whiteColor);
  465.         if(selectMap){
  466.             CopyBits(backMap, &gPredict->portBits, &gPredict->portRect, &gPredict->portRect, srcCopy, nil);
  467.         }
  468.         ValidRectOffscreen(((OffscreenPeek)gPredict)->fBackHandle, nil, &gPredict->portRect);
  469.     }
  470.     PopClip(PRED_CLIP);
  471. }